package com.ht.module.bus.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.util.StringUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.util.CollectionUtils;
import com.ht.module.bus.service.IBusFileService;
import com.ht.util.*;
import com.ht.module.bus.entity.BusFile;

import javax.validation.Valid;
import java.util.*;


/**
 * <p>
 * 业务文件关联表 前端控制器
 * </p>
 *
 * @author Auto-generator
 * @since 2021-12-03
 */
@Api(tags = "业务文件关联表 ")
@RestController
@RequestMapping("/bus-file")
public class BusFileController {

    
    @Autowired
    private IBusFileService iBusFileService;


    @ApiOperation(value = "列表查询")
    @GetMapping("/notLogin/findList")
    public JsonResult findList(BusFile busFile){
        return JsonResult.success(iBusFileService.findList(busFile));
    }


    /**
    * 分页查询
    */
    @ApiOperation(value = "分页查询")
    @GetMapping("/findPage")
    public JsonResult findPage(Pager<BusFile> pager, BusFile busFile){
        return JsonResult.success(iBusFileService.page(pager));
    }


    /**
    * 通过id查询
    */
    @GetMapping("/get-by-id/{id}")
    @ApiOperation(value = "通过id查询")
    public JsonResult getById(@PathVariable(value = "id") String id){
        return JsonResult.success(iBusFileService.getById(id));
    }

    /**
    * 新增
    */
    @PostMapping("/add")
    @ApiOperation(value = "新增")
    public JsonResult add(@Valid BusFile busFile){
        iBusFileService.add(busFile);
        return JsonResult.success(busFile);
    }

    /**
    * 通过id删除
    */
    @DeleteMapping("/delete-by-id/{id}")
    @ApiOperation(value = "删除")
    public JsonResult delete(@PathVariable(value = "id") String id){
        iBusFileService.removeById(id);
        return JsonResult.success();
    }

    /**
    * 修改
    */
    @PutMapping("/update")
    @ApiOperation(value = "修改")
    public JsonResult updateById(@RequestBody @Valid BusFile busFile){
        iBusFileService.updateById(busFile);
        return JsonResult.success();
    }

}
